﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Foundation;
using Windows.Foundation.Collections;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using Windows.UI.Xaml.Controls.Primitives;
using Windows.UI.Xaml.Data;
using Windows.UI.Xaml.Input;
using Windows.UI.Xaml.Media;
using Windows.UI.Xaml.Navigation;

// The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238
using WinRTXamlToolkit.Controls.DataVisualization.Charting;

namespace Wimm.UI.Pages
{
    /// <summary>
    /// An empty page that can be used on its own or navigated to within a Frame.
    /// </summary>
    public sealed partial class MonthDiagram : Page
    {
        public class FinancialStuff
        {
            public string Name { get; set; }
            public int Amount { get; set; }
        }
        public MonthDiagram()
        {
            this.InitializeComponent();
            this.Loaded += PageDiagram_Loaded;
        }

        private void PageDiagram_Loaded(object sender, RoutedEventArgs e)
        {
            LoadChartContents();
        }

        private void LoadChartContents()
        {
            Random rand = new Random();
            ObservableCollection<FinancialStuff> financialStuffList = new ObservableCollection<FinancialStuff>();
            financialStuffList.Add(new FinancialStuff() { Name = "Food", Amount = rand.Next(0, 2000) });
            financialStuffList.Add(new FinancialStuff() { Name = "Transport", Amount = rand.Next(0, 2000) });
            financialStuffList.Add(new FinancialStuff() { Name = "Car", Amount = rand.Next(0, 2000) });
            financialStuffList.Add(new FinancialStuff() { Name = "Children", Amount = rand.Next(0, 2000) });
            (PieChart.Series[0] as PieSeries).ItemsSource = financialStuffList;
        }

        private void ButtonRefresh_Click(object sender, RoutedEventArgs e)
        {
            LoadChartContents();
        }

        private void BackButton_Click(object sender, RoutedEventArgs e)
        {
            this.Frame.Navigate(typeof(HubPage));
        }
    }
}
